package net.csdn.business.notify.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.notify.common.model.entity.NotifyTemplateSeting;
import net.csdn.business.notify.common.model.query.NotifyTemplateSetingQuery;
import net.csdn.business.notify.common.model.vo.NotifyTemplateSetingVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 通知中心-模板配置Mapper接口
 * 
 * @author ruoyi
 * @date 2023-11-27
 */
public interface NotifyTemplateSetingMapper extends BaseMapper<NotifyTemplateSeting>
{

    /**
     * 分页查询通知中心-模板配置列表
     *
     * @param query 字典类型信息
     * @return 字典类型集合信息
     */
    @Results(id="proceessTemplatePage",value={
            @Result(property = "template",column = "template",typeHandler = com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler.class)
    })
    @Select("<script> select * from notify_template_seting where 1=1 " +
            "<if test='query.businessId != null and query.businessId!=\"\"' >" +
            " AND business_id=#{query.businessId} " +
            "</if>" +
            "<if test='query.notifyChannel != null ' >" +
            " AND notify_channel=#{query.notifyChannel} " +
            "</if>" +
            "<if test='query.state != null ' >" +
            " AND state=#{query.state} " +
            "</if>" +
            "<if test='query.createdBy != null and query.createdBy!=\"\"' >" +
            " AND created_by = #{createdBy} " +
            "</if>" +
            " order by created_date desc " +
            "</script>")
    public List<NotifyTemplateSetingVO> findPageList(Page page, @Param("query") NotifyTemplateSetingQuery query);

    /**
     * 查询通知中心-模板配置
     * 
     * @param id 通知中心-模板配置主键
     * @return 通知中心-模板配置
     */
    @Results(id="proceessTemplateDetail",value={
            @Result(property = "template",column = "template",typeHandler = com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler.class)
    })
    @Select("<script> select * from notify_template_seting where id= #{id} </script>")
    public NotifyTemplateSetingVO selectNotifyTemplateSetingById(Long id);

    /**
     * 查询通知中心-模板配置列表
     * 
     * @param query 通知中心-模板配置
     * @return 通知中心-模板配置集合
     */
    @Results(id="proceessTemplateList",value={
            @Result(property = "template",column = "template",typeHandler = com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler.class)
    })
    @Select("<script> select * from notify_template_seting where 1=1 " +
            "<if test='query.businessId != null and query.businessId!=\"\"' >" +
            " AND business_id=#{query.businessId} " +
            "</if>" +
            "<if test='query.notifyChannel != null ' >" +
            " AND notify_channel=#{query.notifyChannel} " +
            "</if>" +
            "<if test='query.state != null ' >" +
            " AND state=#{query.state} " +
            "</if>" +
            "<if test='query.createdBy != null and query.createdBy!=\"\"' >" +
            " AND created_by = #{createdBy} " +
            "</if>" +
            " order by created_date asc " +
            "</script>")
    public List<NotifyTemplateSetingVO> selectNotifyTemplateSetingList(@Param("query") NotifyTemplateSetingQuery query);


    /**
     * 删除通知中心-模板配置
     * 
     * @param id 通知中心-模板配置主键
     * @return 结果
     */
    @Delete("<script> delete from notify_template_seting where id= #{id} </script>")
    public Integer deleteNotifyTemplateSetingById(Long id);

}
